﻿//题目描述
//​定义一个抽象的计算类Operation，该类有两个数据成员numberA和numberB，都是int型，分别用于表示要操作的两个数。
//该类还有一个纯虚函数getResult，代表对numberA和numberB的某种计算并返回结果。由Operation类派生出加法类Add、
//减法类Sub、乘积类Product以及平方和类SumOfSquares，并在这四个派生类中实现基类中的纯虚函数。在主函数中创建加法类、减法类、
//乘积类和平方和类的对象并定义一个Operation类的指针，用Operation类的指针指向不同派生类的对象，然后通过该指针调用getResult函数计算并输出结果。
//
//main函数已经完成，请根据main函数完成类的设计：
#include<iostream>
#include<string>
using namespace std;
class Operation
{
	int numberA;
	int numberB;
public:
Operation(){}
Operation(int a,int b){}
virtual int getResult()=0;
};

class Add:public Operation
{
	int numberA;
	int numberB;
public:
	Add(int a, int b)
	{
		numberA = a;
		numberB = b;
	}
	int getResult() { return numberA + numberB; }
};

class Sub :public Operation
{
	int numberA;
	int numberB;
public:
	Sub(int a,int b):numberA(a),numberB(b){}
	int getResult() { return numberA - numberB; }
};

class Product :public Operation
{

	int numberA;
	int numberB;
public:
	Product(int a, int b) :numberA(a), numberB(b) {}
	int getResult() { return numberA * numberB; }
};

class SumOfSquares :public Operation
{

	int numberA;
	int numberB;
public:
	SumOfSquares(int a, int b) :numberA(a), numberB(b) {}
	int getResult() { return numberA* numberA+ numberB*numberB; }
};
int main() {
	int numA, numB;
	cin >> numA >> numB;
	Add add(numA, numB);	  //和	 
	Sub sub(numA, numB);  //差 
	Product pro(numA, numB);  //乘积 
	SumOfSquares sos(numA, numB); //平方和 
	Operation* op;
	op = &add;
	cout << op->getResult() << endl;
	op = &sub;
	cout << op->getResult() << endl;
	op = &pro;
	cout << op->getResult() << endl;
	op = &sos;
	cout << op->getResult() << endl;
	return 0;
}